package com.cloudptt.api.product.func.crsc;

import com.cloudptt.api.comm.Common;
import com.cloudptt.api.product.log.Log;
import com.mcptt.config.body.pidf.PidfXmlBody;
import com.mcptt.db.model.AddrInfo;

public class FuncNumOb {
    private String funcNum = null;
    private String funcNumDesc = null;
    private String user = null;
    private String userDesc = null;
    private boolean isActive = false;
    private String dateStr = null;

    private boolean isSelected = false;
    public FuncNumOb(String funcNum,boolean isActive)
    {
        this.funcNum = funcNum;
        this.funcNumDesc = AddrInfo.toNumFromSipUrl(funcNum);
        this.isActive = isActive;
        this.dateStr = Common.getDateAndTimeStr();
    }

    public boolean isSameOne(FuncNumOb ob)
    {
        Log.debug(this.getClass(), "isSameOne ob.getFuncNum() = " + ob.getFuncNum() + " funcNum = " + funcNum);
        if(ob != null
            && ob.getFuncNum() != null
            && ob.getFuncNum().equals(funcNum))
        {
            Log.debug(this.getClass(), "isSameOne return true");
            return  true;
        }
        Log.debug(this.getClass(), "isSameOne return false");
        return false;
    }

    public boolean isSameOne(String num)
    {
        if(num != null
                && num.equals(funcNum))
        {
            return  true;
        }
        return false;
    }
    public boolean isSameNumOne(String num)
    {
        if(num != null
                && num.equals(funcNum))
        {
            return  true;
        }
        return false;
    }

    public String getFuncNum() {
        return funcNum;
    }

    public String getFuncNumDesc() {
        return funcNumDesc;
    }

    public boolean isActive() {
        return isActive;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
        Log.debug(this.getClass(),"setUser user = " + user);
        if(user != null) {
            this.userDesc = AddrInfo.toNumFromSipUrl(user);
        }
    }
    public String getUserDesc() {
        return userDesc;
    }
    public boolean isSelected() {
        return isSelected;
    }

    public void setSelected(boolean selected) {
        isSelected = selected;
    }

    public String getDateStr() {
        return dateStr;
    }
    public AddrInfo toAddrInfo()
    {
        AddrInfo info = new AddrInfo(AddrInfo.UserType_User,funcNum, funcNum,AddrInfo.DEFAULT_ATTR);
        return info;
    }

    public String toString()
    {
        StringBuffer strBuf = new StringBuffer();
        strBuf.append("funcNum = ").append(funcNum).append(",");
        strBuf.append("isActive = ").append(isActive).append(",");
        strBuf.append("user = ").append(user).append(",");
        strBuf.append("userDesc = ").append(userDesc).append(",");
        strBuf.append("funcNumDesc = ").append(funcNumDesc).append(",");

        return strBuf.toString();
    }
}
